package org.hackystat.devcathlon.ui.page.scoreboard;

import static org.junit.Assert.assertNotNull;
import org.apache.wicket.util.tester.FormTester;
import org.apache.wicket.util.tester.WicketTester;
import org.hackystat.devcathlon.configuration.ConfigurationException;
import org.hackystat.devcathlon.engine.test.DevcathlonTestHelper;
import org.hackystat.devcathlon.ui.DevcathlonApplication;
import org.hackystat.devcathlon.ui.page.login.LoginPage;
import org.junit.Test;

/**
 * Tests the ScoreBoard implementation.
 * 
 * @author Daniel Arakaki, Robin Raqueno
 */
public class TestScoreBoardPage extends DevcathlonTestHelper {

  /**
   * Assure the panels are instantiated.
   * 
   * @throws ConfigurationException If problems with configuration.
   */
  @Test
  public void testScoreBoardPage() throws ConfigurationException {
    WicketTester wicketTester = new WicketTester(new DevcathlonApplication());
    
    wicketTester.startPage(ScoreboardPage.class);
    wicketTester.assertRenderedPage(LoginPage.class);
    
    FormTester formTester = wicketTester.newFormTester("loginForm");
    formTester.setValue("user", "admin@hackystat.org");
    formTester.setValue("password", "admin@hackystat.org");
    formTester.submit();
    
    wicketTester.assertRenderedPage(ScoreboardPage.class);
    
    assertNotNull("scores panel ID not found.", wicketTester.getTagByWicketId("scores_panel"));
    assertNotNull("scores panel ID not found.", 
        wicketTester.getTagByWicketId("frontteamleft_panel"));
    
  }
}
